//
//  KKKeyBoardUtils.m
//  DoMi
//
//  Created by 康凯 on 2016/11/30.
//  Copyright © 2016年 kk. All rights reserved.
//

#import "KKKeyBoardUtils.h"

@implementation KKKeyBoardUtils
#pragma mark注册键盘监听
- (void)registerForKeyboardNotifications
{
    //监听键盘出现
    [[NSNotificationCenter defaultCenter] addObserver:self.reply selector:@selector(keyboardShow:) name:UIKeyboardDidShowNotification object:nil];
    //监听键盘隐藏
    [[NSNotificationCenter defaultCenter] addObserver:self.reply selector:@selector(keyboardHidden) name:UIKeyboardWillHideNotification object:nil];
    
}
- (void)unRegisterForKeyboardNotifications
{
    //释放
    [[NSNotificationCenter defaultCenter] removeObserver:self.reply name:UIKeyboardWillShowNotification object:nil];
    [[NSNotificationCenter defaultCenter] removeObserver:self.reply name:UIKeyboardWillHideNotification object:nil];
    
}

-(void)keyboardShow:(NSNotification *)notify{
    NSDictionary* info = [notify userInfo];
    CGSize kbSize = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;
    KKLog(@"---->%f",kbSize.height);
    [self.delegate keyboardShow1:kbSize.height];
}


////实现当键盘出现的时候计算键盘的高度大小
//- (void)keyboardShow11:(NSNotification*)aNotification
//{
//    NSDictionary* info = [aNotification userInfo];
//    //获取键盘高度
//    CGSize kbSize = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;
//    KKLog(@"---->%f",kbSize.height);
//    [self.delegate keyboardShow:kbSize.height];
//}
//
//当键盘隐藏的时候
- (void)keyboardHidden
{
    [self.delegate keyboardHidden1];
}
@end
